ColdFusion Article

Creating Globalized ColdFusion Applications


Table of Contents

  1. Introduction
  2. Globalization Changes in ColdFusion MX
  3. Good Practices: Obstacles in Developing I18N Applications
  4. Good Practices (cont): Encoding, Unicode, HTML
  5. Good Practices (cont): Locale Determination, Locale-Specific Formatting, Time Zones
  6. Good Practices (cont): ResourceBundles,Application Framework, User Specific, Server Specific

Good Practices

Modesty and good sense wouldn’t let me title this section best practices. I actually wanted to call it, "what I think is a fairly good idea at the moment," but again thought better. So why not call it, best practices? Because there are many ways to skin a globalized cat and I truly believe (and perhaps you do too) that developers have not yet fully exploited the excellent opportunities provided by CFCs for G11N applications. I think we’ll see some fantastic development coming from the introduction of CFCs. What I discuss below is what I know works today. Before we begin, keep in mind one guiding principal: universal access.

Any universally accessible application must accomplish three basic things:

  1. It must be internationalized (which I address here).
  2. It must be accessible to any user no matter their physical limitations.
  3. It must be device independent.

To globalize, you must first internationalize. First, however, let’s examine some of the things developers do that hinder I18N.

Obstacles in Developing I18N Applications

Any application designed without I18N in mind will usually be full of obstacles to internationalizing it. Some impediments you should be aware of:

  • Using a database that doesn’t support Unicode. This is fatal. If your database doesn’t support Unicode, get rid of it. Fortunately most of the modern big iron databases such as MS SQL Server, Oracle and their brethren and some of the more popular databases, such as MS Access 2000, support Unicode.
  • Designing your database to accommodate only one culture. There are no hard and fast rules for this, you will need to research or hire someone who has researched; but in general, keep in mind the following:
    • Require almost nothing cultural. For instance names can consist of one, two or three parts, requiring more than one will obviously not work everywhere. Let locale-based rules in the ColdFusion part of the application handle required data. Be especially aware of non-ColdFusion applications accessing your databases, these often do not play by I18N rules.
    • English is rather a precise, economical language. In comparison, non-English language terms, names, and so forth are sometimes longer than their English equivalent or consist of more than one word. This is especially true of highly technical terms, such as medical terminology. For instance the Thai equivalent of "abdominal aorta" consists of more than a dozen words. Make columns that hold text wider than you think necessary.
    • Snail mail addresses should have enough flexibility to handle the various address styles and should also not require anything. Postal codes should not assume numeric data. Your "street" design should allow for more than one street part. Don’t assume that identifiers are always house numbers/street addresses, any patterns (left side odd, right side even), or regular sequences (house #3 might not come after house #1). Let locale-based rules determine the display format for addresses.
    • Don’t assume measurement units. Separate measurement units from measurement values. The whole world isn’t metric. This also applies to clothing and shoe sizes, which vary wildly from locale to locale.
  • Not storing datetime data as UTC (Universal Time Coordinate or Greenwich Mean Time). If your servers are physically distributed across many time zones or you wish to "cast" your datetime data to different time zones, it’s a good idea to keep your data as UTC.
  • Presuming Gregorian calendar system for your datetime data. There are at least five other major calendar systems in use today: Buddhist, Chinese, Hebrew, Islamic and Japanese. While its often acceptable to use the Gregorian calendar with localized date formats, that’s not true everywhere, its not AD 2003 to everyone. This is especially critical for date-based calculations.
  • Not using CSS. Some folks might frown on using style sheets, but try replacing gobs of individual HTML formatting locale by locale. This is one bias I can guarantee you will grow out of quickly.
  • Assuming text or graphic directionality. Not everyone looks at a page of text and graphics the same way. People in Arabic cultures read and understand text and graphics right to left.
  • Mixing text/text presentation and application code. This is probably the dreariest part of making an existing application I18N ready. You must hunt down each wayward bit of hard-coded text and replace them with ColdFusion variables of one sort or another. Looking on the bright side, this is an excellent opportunity to untangle any spaghetti code.
  • Not using UTF-8 encoding. The path of least resistance through ColdFusion to globalization is through Unicode. If you want to easily serve as many languages as you can, use Unicode. If you don't want to have to manage encodings per locale, use Unicode. The most popular and widely supported Unicode transformation format is of course UTF-8. It’s also the default encoding for ColdFusion—so use it. If you want to save yourself the trouble of peppering your ColdFusion pages with <CFPROCESSINGDIRECTIVE> tags, it would be a good idea to use an editor, such as Dreamweaver, which supports a BOM (byte order mark) so that the ColdFusion server will automatically understand your page’s encoding.

Now that I’ve highlighted some of the major I18N obstacles, let’s examine some other things to consider.